<?php

namespace JLPay\Models\Openmerch\Device;

use JLPay\Models\BaseRequest;

/**
 * 终端查询请求
 * 
 * @author liaochangyi
 * @since 2025-01-25
 */
class DeviceQueryRequest extends BaseRequest
{
    /**
     * API URL
     */
    public const API_URL = '/open/merch/access/device/query';

    protected ?string $merchNo = null;      // 商户号，终端号、机身号不传查该商户下所有的终端信息
    protected ?string $termNo = null;       // 终端编号，填入终端号时查询该终端号的终端信息，终端号必须为该商户号下的终端
    protected ?string $deviceNo = null;     // 设备硬件序列号（SN），填入机身号时查询该设备的终端信息，机身号必须该商户号下加机绑定的设备对应的机身号

    /**
     * 设置商户号
     *
     * @param string $merchNo
     * @return self
     */
    public function setMerchNo(string $merchNo): self
    {
        $this->merchNo = $merchNo;
        return $this;
    }

    /**
     * 设置终端编号
     *
     * @param string $termNo
     * @return self
     */
    public function setTermNo(string $termNo): self
    {
        $this->termNo = $termNo;
        return $this;
    }

    /**
     * 设置设备硬件序列号
     *
     * @param string $deviceNo
     * @return self
     */
    public function setDeviceNo(string $deviceNo): self
    {
        $this->deviceNo = $deviceNo;
        return $this;
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMerchNo(): ?string
    {
        return $this->merchNo;
    }

    /**
     * 获取终端编号
     *
     * @return string|null
     */
    public function getTermNo(): ?string
    {
        return $this->termNo;
    }

    /**
     * 获取设备硬件序列号
     *
     * @return string|null
     */
    public function getDeviceNo(): ?string
    {
        return $this->deviceNo;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data['merch_no'] = $this->merchNo;
        $data['term_no'] = $this->termNo;
        $data['device_no'] = $this->deviceNo;
        return $data;
    }
} 